public class BankAccount {

    public String account;
    public int balance;

    public BankAccount(int a,String b){
        this.balance=a;
        this.account=b;
    }

    public void getAccount(int x){
        if(balance<=0||x>balance){
            System.out.println("账户余额不足!");
            return;
        }
        else{
            balance=balance-x;
            System.out.println("成功取出"+x+"元");
        }
    }

    public void putAccount(int x){
        balance=balance+x;
        System.out.println("成功存入"+x+"元");
    }

    public void checkBalance(){
        System.out.println("当前余额为"+balance+"元");
    }

    public void displayAccount(){
        System.out.println("当前账户为："+account);
    }
}

class Test2{
    public static void main(String[]args){
        BankAccount bankAccount=new BankAccount(100,"yang");
        bankAccount.displayAccount();
        bankAccount.checkBalance();
        bankAccount.getAccount(50);
        bankAccount.checkBalance();

    }

}

